from openpyxl import load_workbook
from config import grade
def getGrade(cls):
    for i in grade:
        if cls in grade[i]:
            return i
courseList={
    "七年级":["","阅读","演讲","朗诵"],
    "八年级":["演讲","","朗诵","阅读"],
    "九年级":["朗诵","演讲","","阅读"],
}
mondayColum=4
def renameCourse(cls,col):
    g=getGrade(cls)
    course_=courseList[g]
    if(course_[col]==""):
        print("error:无课")
    else:
        cells=sheet.cell(row=30,column=mondayColum+col)
        cells.value=course_[col]
wb=load_workbook(filename="课程表2025.3.10  11.24.xlsx")
list=wb.sheetnames
for sheet in wb.worksheets:
    cell=sheet["I3"]
    if(cell.value[-1] =="班"):
        for c in range(4):
            renameCourse(cell.value,c)
    else:
        for c in range(4):
            cl=sheet.cell(row=31,column=mondayColum+c)
            cl=cl.value
            if(cl != "" and cl != None) :
                cl=cl[1:-1]
                renameCourse(cl,c)
                print(cl)

wb.save(filename="课程表.xlsx")